﻿using System;
using System.Windows;
using System.Windows.Media.Animation;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MediaXenterWPF
{
    public static class AnimationHelper
    {
        public static DoubleAnimation AnimationScaleY(Duration duration, DependencyObject value, double from, double to)
        {           
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.Duration = duration;
            Storyboard.SetTarget(myDoubleAnimation, value);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;

            return myDoubleAnimation;

        }

        public static DoubleAnimation AnimationScaleX(Duration duration, DependencyObject value, double from, double to)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.Duration = duration;
            Storyboard.SetTarget(myDoubleAnimation, value);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;

            return myDoubleAnimation;

        }

        public static DoubleAnimation AnimationTranslateTransformY(Duration duration, DependencyObject value, double from, double to)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.Duration = duration;
            Storyboard.SetTarget(myDoubleAnimation, value);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;

            return myDoubleAnimation;

        }

        public static DoubleAnimation AnimationTranslateTransformX(Duration duration, DependencyObject value, double from, double to)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.Duration = duration;
            Storyboard.SetTarget(myDoubleAnimation, value);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"));
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;

            return myDoubleAnimation;

        }
    }
}
